package consumer

import (
	"context"
	"fmt"

	"time"

	"github.com/gin-gonic/gin"

	ginEx "github.com/illidaris/gin"
)

func Run() {
	ctx := context.Background()
	engine := gin.New()
	// add middleware
	engine.Use(
		ginEx.LoggerHandler(),  // 日志
		ginEx.RecoverHandler(), // 异常
		// middleware.CORSMiddleware(),  // 跨域
		// middleware.ParamMiddleware()) // 参数
	)
	AssemblyRoutes(engine)
	port := 12211
	lsn := fmt.Sprintf(":%d", port)
	Consume()
	// run
	ginEx.GracefulRun(ctx, engine, lsn, time.Second*5)
}
